﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Hive.Core.Model.Schema
{
    /// <summary>
    /// An Xml serializable representation of a descriptor property.
    /// </summary>
    [Serializable]
    [XmlType(Namespace = SchemaConstants.XmlNamespace)]
    public sealed class DescriptorProperty
    {
        /// <summary>
        /// Creates an uninitialized descriptor property.
        /// </summary>
        public DescriptorProperty()
        {
        }

        /// <summary>
        /// Creates a descriptor property initialized with the specified key and value.
        /// </summary>
        /// <param name="key">The property key.</param>
        /// <param name="value">The property value.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="key"/> or
        /// <paramref name="value"/> is null.</exception>
        public DescriptorProperty(string key, string value)
        {
            if (key == null)
                throw new ArgumentNullException("key");
            if (value == null)
                throw new ArgumentNullException("value");

            Key = key;
            Value = value;
        }

        /// <summary>
        /// Gets or sets the property key.
        /// </summary>
        [XmlAttribute("key")]
        public string Key { get; set; }

        /// <summary>
        /// Gets or sets the property value.
        /// </summary>
        [XmlAttribute("value")]
        public string Value { get; set; }
    }
}
